package com.atguigu.spzx.cloud.order.controller;

import com.atguigu.spzx.cloud.order.entity.Order;
import com.atguigu.spzx.cloud.order.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * projectName: com.atguigu.spzx.cloud.order.controller
 *
 * @author: 顾司羽
 * time: 2024/12/24 11:36 周二
 * description:
 */
@RestController
@RequestMapping( "/api/order")  //value可以省略
public class OrderController {

    @Autowired
    @Resource //取消飘红线警告
    private OrderService orderService;

    @GetMapping(value = "/findOrderByOrderId/{orderId}")
    public Order findOrderByOrderId(@PathVariable("orderId") Long orderId,
                                    @RequestHeader(value = "gusiyu", required = false)String gusiyu,
                                    @RequestHeader(value = "fuyachong", required = false)String fuyachong) {
        System.out.println("OrderController.findOrderByOrderId");
        System.out.println("orderId = " + orderId + ", gusiyu = " + gusiyu + ", fuyachong = " + fuyachong);


        return orderService.findOrderByOrderId(orderId) ;
    }

    //根据用户id查询订单集合
    @GetMapping("findOrderListByUserId") //因为名字一样，所以可以省略@RequestParam("userId")
    public List<Order> findOrderList(@RequestParam Long userId){
        return orderService.findOrderList(userId);
    }
}
